.class public Lcom/vividsolutions/jts/index/quadtree/Quadtree;
.super Ljava/lang/Object;
.source "Quadtree.java"

# interfaces
.implements Lcom/vividsolutions/jts/index/SpatialIndex;


# instance fields
.field private minExtent:D

.field private root:Lcom/vividsolutions/jts/index/quadtree/Root;


# direct methods
.method public constructor <init>()V
    .locals 2

    .line 112
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    const-wide/high16 v0, 0x3ff0000000000000L    # 1.0

    .line 106
    iput-wide v0, p0, Lcom/vividsolutions/jts/index/quadtree/Quadtree;->minExtent:D

    .line 113
    new-instance v0, Lcom/vividsolutions/jts/index/quadtree/Root;

    invoke-direct {v0}, Lcom/vividsolutions/jts/index/quadtree/Root;-><init>()V

    iput-object v0, p0, Lcom/vividsolutions/jts/index/quadtree/Quadtree;->root:Lcom/vividsolutions/jts/index/quadtree/Root;

    return-void
.end method

.method private collectStats(Lcom/vividsolutions/jts/geom/Envelope;)V
    .locals 7

    .line 205
    invoke-virtual {p1}, Lcom/vividsolutions/jts/geom/Envelope;->getWidth()D

    move-result-wide v0

    .line 206
    iget-wide v2, p0, Lcom/vividsolutions/jts/index/quadtree/Quadtree;->minExtent:D

    const-wide/16 v4, 0x0

    cmpg-double v6, v0, v2

    if-gez v6, :cond_0

    cmpl-double v2, v0, v4

    if-lez v2, :cond_0

    .line 207
    iput-wide v0, p0, Lcom/vividsolutions/jts/index/quadtree/Quadtree;->minExtent:D

    .line 209
    :cond_0
    invoke-virtual {p1}, Lcom/vividsolutions/jts/geom/Envelope;->getWidth()D

    move-result-wide v0

    .line 210
    iget-wide v2, p0, Lcom/vividsolutions/jts/index/quadtree/Quadtree;->minExtent:D

    cmpg-double p1, v0, v2

    if-gez p1, :cond_1

    cmpl-double p1, v0, v4

    if-lez p1, :cond_1

    .line 211
    iput-wide v0, p0, Lcom/vividsolutions/jts/index/quadtree/Quadtree;->minExtent:D

    :cond_1
    return-void
.end method

.method public static ensureExtent(Lcom/vividsolutions/jts/geom/Envelope;D)Lcom/vividsolutions/jts/geom/Envelope;
    .locals 19

    .line 77
    invoke-virtual/range {p0 .. p0}, Lcom/vividsolutions/jts/geom/Envelope;->getMinX()D

    move-result-wide v0

    .line 78
    invoke-virtual/range {p0 .. p0}, Lcom/vividsolutions/jts/geom/Envelope;->getMaxX()D

    move-result-wide v2

    .line 79
    invoke-virtual/range {p0 .. p0}, Lcom/vividsolutions/jts/geom/Envelope;->getMinY()D

    move-result-wide v4

    .line 80
    invoke-virtual/range {p0 .. p0}, Lcom/vividsolutions/jts/geom/Envelope;->getMaxY()D

    move-result-wide v6

    cmpl-double v8, v0, v2

    if-eqz v8, :cond_0

    cmpl-double v8, v4, v6

    if-eqz v8, :cond_0

    return-object p0

    :cond_0
    const-wide/high16 v8, 0x4000000000000000L    # 2.0

    cmpl-double v10, v0, v2

    if-nez v10, :cond_1

    div-double v2, p1, v8

    sub-double/2addr v0, v2

    add-double/2addr v2, v0

    :cond_1
    move-wide v11, v0

    move-wide v13, v2

    cmpl-double v0, v4, v6

    if-nez v0, :cond_2

    div-double v0, p1, v8

    sub-double/2addr v4, v0

    add-double v6, v4, v0

    :cond_2
    move-wide v15, v4

    move-wide/from16 v17, v6

    .line 93
    new-instance v0, Lcom/vividsolutions/jts/geom/Envelope;

    move-object v10, v0

    invoke-direct/range {v10 .. v18}, Lcom/vividsolutions/jts/geom/Envelope;-><init>(DDDD)V

    return-object v0
.end method


# virtual methods
.method public insert(Lcom/vividsolutions/jts/geom/Envelope;Ljava/lang/Object;)V
    .locals 2

    .line 141
    invoke-direct {p0, p1}, Lcom/vividsolutions/jts/index/quadtree/Quadtree;->collectStats(Lcom/vividsolutions/jts/geom/Envelope;)V

    .line 142
    iget-wide v0, p0, Lcom/vividsolutions/jts/index/quadtree/Quadtree;->minExtent:D

    invoke-static {p1, v0, v1}, Lcom/vividsolutions/jts/index/quadtree/Quadtree;->ensureExtent(Lcom/vividsolutions/jts/geom/Envelope;D)Lcom/vividsolutions/jts/geom/Envelope;

    move-result-object p1

    .line 143
    iget-object v0, p0, Lcom/vividsolutions/jts/index/quadtree/Quadtree;->root:Lcom/vividsolutions/jts/index/quadtree/Root;

    invoke-virtual {v0, p1, p2}, Lcom/vividsolutions/jts/index/quadtree/Root;->insert(Lcom/vividsolutions/jts/geom/Envelope;Ljava/lang/Object;)V

    return-void
.end method

.method public query(Lcom/vividsolutions/jts/geom/Envelope;)Ljava/util/List;
    .locals 1

    .line 179
    new-instance v0, Lcom/vividsolutions/jts/index/ArrayListVisitor;

    invoke-direct {v0}, Lcom/vividsolutions/jts/index/ArrayListVisitor;-><init>()V

    .line 180
    invoke-virtual {p0, p1, v0}, Lcom/vividsolutions/jts/index/quadtree/Quadtree;->query(Lcom/vividsolutions/jts/geom/Envelope;Lcom/vividsolutions/jts/index/ItemVisitor;)V

    .line 181
    invoke-virtual {v0}, Lcom/vividsolutions/jts/index/ArrayListVisitor;->getItems()Ljava/util/ArrayList;

    move-result-object p1

    return-object p1
.end method

.method public query(Lcom/vividsolutions/jts/geom/Envelope;Lcom/vividsolutions/jts/index/ItemVisitor;)V
    .locals 1

    .line 190
    iget-object v0, p0, Lcom/vividsolutions/jts/index/quadtree/Quadtree;->root:Lcom/vividsolutions/jts/index/quadtree/Root;

    invoke-virtual {v0, p1, p2}, Lcom/vividsolutions/jts/index/quadtree/NodeBase;->visit(Lcom/vividsolutions/jts/geom/Envelope;Lcom/vividsolutions/jts/index/ItemVisitor;)V

    return-void
.end method
